<template>
	<view class="setting">
		<view class="content">
			<view class="switch">
				<text>免审设置</text>
				<u-switch v-model="checked" @change="change" :size="40"></u-switch>
			</view>
			<view class="desc">
				开启免审核功能，本部门内干事提交反馈后不需经过部门领导审核，即可直接反馈给中台。
			</view>
		</view>
	</view>
</template>

<script>
	import { apiChangeMsh, apiGetMsh } from '@/api/audit/audit.js'
	export default {
		data () {
			return {
				checked: false,
				status: 1,
			}
		},
		onLoad() {
			this.apiGetMsh();
		},
		methods: {
			change (status) {
				this.checked = status;
				if (this.checked) {
					this.status = 2;
					this.apiChangeMsh(2);
				} else {
					this.status = 1;
					this.apiChangeMsh(1);
				}
			},
			// 设置免审核
			async apiChangeMsh (msh) {
				const res = await apiChangeMsh(msh);
			},
			//获取免审核状态
			async apiGetMsh () {
				const res = await apiGetMsh();
				this.status = Number(res.data);
				if (this.status === 1) {
					this.checked = false;
				} else {
					this.checked = true;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.setting {
		padding: 30rpx;
		
		.content {
			padding: 40rpx;
			width: 690rpx;
			height: 210rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 10rpx 20rpx 0rpx #B6D8FF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			opacity: 1;
			
			.switch {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			
			.desc {
				margin-top: 30rpx;
				font-size: 26rpx;
				font-family: SourceHanSansCN-Normal, SourceHanSansCN;
				font-weight: 400;
				color: #5F6474;
				line-height: 40rpx;
			}
		}
	}
</style>
